
#ifndef __CONTROLLER_TYPES__H_
#define __CONTROLLER_TYPES__H_

#include <stdint.h>
#include <string.h>
#include <time.h>

typedef uint32_t user_pin_t;

enum {
	EV_T_Card = 0,
	EV_T_Key = 1,
};

#define USER_F_VALID		0x01		//用户有效
#define USER_F_ADMIN		0x02		//管理员用户

typedef struct _input_event{
	uint8_t type;
	uint8_t len;
	uint8_t data[8];
}input_event_t;

static inline input_event_t* input_event_build(input_event_t* e, uint8_t type, const void* data, uint8_t len){
	e->type = type;
	e->len = len;
	memcpy(e->data, data, len);
	return e;
}

#pragma pack(1)
typedef struct _user_token{
//		uint8_t type;
	uint8_t len;
	uint8_t data[8];
}user_token_t;

typedef struct _user_info{
	user_pin_t pin;
	uint32_t time_start;
	uint32_t time_end;
	user_token_t card;
	user_token_t pwd;
	uint8_t flag;
	uint8_t check_sum;
}user_info_t;

#pragma pack()

#endif 


